package com.demo.connectdbtest.module.page.controller;

import com.demo.connectdbtest.module.page.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/page")
public class PageController {

    @GetMapping("/toTestPage")
    public String toTestPage() {

        return "testHtml";
    }

    @GetMapping("/getNameList")
    @ResponseBody
    public List<Student> getNameList() {
        ArrayList<Student> students = new ArrayList<>();
        Student student = new Student();
        student.setNumber("9785");
        student.setId(1);
        student.setName("王一博");
        Student student1 = new Student();
        student1.setNumber("1007");
        student1.setId(2);
        student1.setName("张艺兴");
        students.add(student);
        students.add(student1);
        return students;
    }
}
